-
-
Notifications
You must be signed in to change notification settings - Fork 996
bench: refactor random number generation in stats/base/dists/kumaraswamy
#5019
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: na
- task: lint_package_json
status: na
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: na
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: na
- task: lint_javascript_benchmarks
status: passed
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: na
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
---
type: pre_push_report
description: Results of running various checks prior to pushing changes.
report:
- task: run_javascript_examples
status: na
- task: run_c_examples
status: na
- task: run_cpp_examples
status: na
- task: run_javascript_readme_examples
status: na
- task: run_c_benchmarks
status: na
- task: run_cpp_benchmarks
status: na
- task: run_fortran_benchmarks
status: na
- task: run_javascript_benchmarks
status: na
- task: run_julia_benchmarks
status: na
- task: run_python_benchmarks
status: na
- task: run_r_benchmarks
status: na
- task: run_javascript_tests
status: na
---
stats/base/dists/kumaraswamystats/base/dists/kumaraswamy
stats/base/dists/kumaraswamystats/base/dists/kumaraswamy
stats/base/dists/kumaraswamystats/base/dists/kumaraswamy
---
type: pre_push_report
description: Results of running various checks prior to pushing changes.
report:
- task: run_javascript_examples
status: na
- task: run_c_examples
status: na
- task: run_cpp_examples
status: na
- task: run_javascript_readme_examples
status: na
- task: run_c_benchmarks
status: na
- task: run_cpp_benchmarks
status: na
- task: run_fortran_benchmarks
status: na
- task: run_javascript_benchmarks
status: na
- task: run_julia_benchmarks
status: na
- task: run_python_benchmarks
status: na
- task: run_r_benchmarks
status: na
- task: run_javascript_tests
status: na
---
|
@yuvi-mittal |
|
@Neerajpathak07 , seems like just the benchmarks . |
|
Ohh just had a look at the package and apparently there are no C implementations for it so in turn there is no native file got it! |
|
There C implementation is not done yet , so some of them doesnt have the native benchmarks . |
lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/mode/benchmark/benchmark.js
Show resolved
Hide resolved
|
And primarily you have test failures for |
|
i didnt edit stats/base/dists/kumaraswamy/median/test/test.native , But i will check and resolve the error |
Alright I understood where the problem lies, so the |
|
For reference take a look at test.js and test.native.js and comapre between the two. |
stats/base/dists/kumaraswamystats/base/dists/kumaraswamy
|
@kgryte What are your views on this? |
|
Both test.js and test.native.js need to be refactored . I will open an issue for this and raise a separate PR . But how did it get merged in the first place ? |
|
You can draft this PR for the time being |
| dist.a = y[i % len]; | ||
| if ( dist.a !== y[i % len] ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| dist.a = y[i % len]; | |
| if ( dist.a !== y[i % len] ) { | |
| dist.a = y[ i % len ]; | |
| if ( dist.a !== y[ i % len ] ) { |
| dist.b = y[i % len]; | ||
| if ( dist.b !== y[i % len] ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same change as above.
| x[ i ] = uniform( EPS, 2.0 ); | ||
| a[ i ] = uniform( EPS, 100.0 ); | ||
| s[ i ] = uniform( EPS, 100.0 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| x[ i ] = uniform( EPS, 2.0 ); | |
| a[ i ] = uniform( EPS, 100.0 ); | |
| s[ i ] = uniform( EPS, 100.0 ); | |
| x[ i ] = uniform( 0.0, 1.0 ); | |
| a[ i ] = uniform( EPS, 5.0 ); | |
| s[ i ] = uniform( EPS, 5.0 ); |
| len = 100; | ||
| x = new Float64Array( len ); | ||
| for ( i = 0; i < len; i++ ) { | ||
| x[ i ] = uniform( EPS, 2.0 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| x[ i ] = uniform( EPS, 2.0 ); | |
| x[ i ] = uniform( -2.0, 2.0 ); |
| x[ i ] = uniform( EPS, 2.0 ); | ||
| a[ i ] = uniform( EPS, 100.0 ); | ||
| s[ i ] = uniform( EPS, 100.0 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same change as above. This also applies to other functions, where applicable ( for eg. logpdf, etc.)
| var uniform = require( '@stdlib/random/base/uniform' ); | ||
| var Float64Array = require( '@stdlib/array/float64' ); | ||
| var isnan = require( '@stdlib/math/base/assert/is-nan' ); | ||
| var EPS = require( '@stdlib/constants/float64/eps' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is EPS needed here?
| var alpha; | ||
| var beta; | ||
| var len; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| var alpha; | |
| var beta; | |
| var len; | |
| var len; | |
| var a; | |
| var s; |
| alpha = new Float64Array( len ); | ||
| beta = new Float64Array( len ); | ||
| for ( i = 0; i < len; i++ ) { | ||
| x[ i ] = uniform( EPS, 2.0 ); | ||
| alpha[ i ] = uniform( EPS, 100.0 ); | ||
| beta[ i ] = uniform( EPS, 100.0 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| alpha = new Float64Array( len ); | |
| beta = new Float64Array( len ); | |
| for ( i = 0; i < len; i++ ) { | |
| x[ i ] = uniform( EPS, 2.0 ); | |
| alpha[ i ] = uniform( EPS, 100.0 ); | |
| beta[ i ] = uniform( EPS, 100.0 ); | |
| a = new Float64Array( len ); | |
| s = new Float64Array( len ); | |
| for ( i = 0; i < len; i++ ) { | |
| x[ i ] = uniform( EPS, 2.0 ); | |
| a[ i ] = uniform( EPS, 100.0 ); | |
| s[ i ] = uniform( EPS, 100.0 ); |
| a = ( randu()*100.0 ) + EPS; | ||
| s = ( randu()*100.0 ) + EPS; | ||
| y = pdf( x, a, s ); | ||
| y = pdf( x[ i % len ], alpha[ i % len ], beta[ i % len ] ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| y = pdf( x[ i % len ], alpha[ i % len ], beta[ i % len ] ); | |
| y = pdf( x[ i % len ], a[ i % len ], s[ i % len ] ); |
| var alpha; | ||
| var beta; | ||
| var len; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same changes as above.
Great catch! This is the related PR: stdlib-js/stdlib#4020. I just checked: This line:
should be: return stdlib_base_pow( 1.0 - stdlib_base_pow( 2.0, -1.0 / b ), 1.0 / a );The original line is only correct when Just checked it locally too, this fix also makes all native tests pass. A PR addressing this would be a great addition! |
Yeah, and additionally we do need to add a few test cases to implicitly test a few technicalities what do you say? |
Do you have any in mind? I think |
Yeah, that's correct I was thinking of testing if the function returns |
Even after changing the test cases aren't still passing in my system . I will have to go through the test cases once . Are you sure it is passing in locally in your system? @anandkaranubc |
Once you change anything in the C implementation side, you will have to build the native addon again |
|
We have moved to using var uniform = require( '@stdlib/random/array/uniform' ); instead of var uniform = require( '@stdlib/random/base/uniform' ); to directly draw arrays filled with numbers from the desired distribution. Since this PR follows our older convention and now has merge conflicts, I am going to close it. Thanks for your contribution either way, it is appreciated! |
Resolves #4975
Description
This pull request:
Related Issues
This pull request:
stats/base/dists/kumaraswamy#4975Questions
No.
Other
No.
Checklist
@stdlib-js/reviewers